
fn bindings(){
    let an_integer = 1u32;
    let a_boolean = true;
    let unit = ();

    let copied_integer = an_integer;

    println!("An integer: {:?}", copied_integer);
    println!("A boolean: {:?}", a_boolean);
    println!("Meet the unit value: {:?}", unit);

    let _unused_variable = 3u32;

    let _noisy_unused_variable = 2u32;
}

fn mutability(){
    let _immutable_binding = 1;
    let mut mutable_binding = 1;

    println!("Before mutation: {}", mutable_binding);

    mutable_binding += 2;
    println!("After mutation: {}", mutable_binding);


    //COMPILE ERROR: _immutable_binding += 1;
}


fn scope_shadowing(){
    let long_lived_binding = 1;
    {
        let short_lived_binding = 2;
        println!("inner short: {}", short_lived_binding);
    }

    //lost scope : println!("outer short: {}", short_lived_binding);
    println!("outer long: {}", long_lived_binding);


    let shadowed_binding = 1;
    {
        println!("before being shadowed: {}", shadowed_binding);

        let shadowed_binding = "abc";
        println!("shadowed in inner block: {}", shadowed_binding);
    }
    println!("outside inner block: {}", shadowed_binding);
    
    let shadowed_binding = 2;
    println!("shadowed in outer block: {}", shadowed_binding);
}


pub fn main(){
    bindings();
    mutability();
    scope_shadowing();
}
